﻿/*
*	斯坦福锁相
*
*
*
*/


//依赖项：
//mfcvcr100.dll;kernel32.dll

#include "../common/serialport.h"
#include "../common/read_dev_head.h"

serialPort com;
static OVERLAPPED ov= { 0 } ;


//dll入口
BOOL APIENTRY DllMain( HANDLE hModule,
	DWORD  ul_reason_for_call, 
	LPVOID lpReserved
	)
{
	switch( ul_reason_for_call )
	{
	case DLL_PROCESS_ATTACH:break;
	case DLL_THREAD_ATTACH:break;
	case DLL_THREAD_DETACH:break;
	case DLL_PROCESS_DETACH:
		com.CloseCom();
	}
	return TRUE;
}


//
bool getx(char*dat) 
{
	send("OUTP?1\r");
	waitcom();
	Sleep(10);//防止数据分2行发送过来
	return read(dat);
}
bool gety(char*dat) 
{
	if(!send("OUTP?2\r"))
	{
		return false;
	}
	waitcom();
	Sleep(10);
	return read(dat);
}
bool getall(char*dat) 
{
	if(!send("OUTP?1;OUTP?2\r"))
	{
		return false;
	}
	waitcom();
	Sleep(10);
	return read(dat);
}


extern "C" __declspec(dllexport) void setupReaderEngine(readerInterface& dest)
{
	dest.openCom=openCom;
	dest.closeCom=closeCom;
		//com.SetMask(EV_RXCHAR);

	dest.pgetx=getx;
	dest.pgety=gety;
	dest.pgetall=getall;
}


